<%
layout("/layouts/platform.html"){
%>
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-default navbar-btn" href="${base}/platform/trainer" data-pjax><i class="ti-angle-left" id="goback"></i> 返回</a>
    </div>
</header>

<div class="panel-body" style="padding-top: 70px;">
		<div class="box">
			<div class="box-body">
				<div class="col-sm-12">
					<div class="row">

       
            <form id="companyAddForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/platform/trainer/addDo" method="post" style="margin-top:30px">
                <div class="row mb10">
                    <div class="col-lg-12">
                    	<div class="form-group">
                            <label for="card_type" class="col-sm-2 control-label">选择驾校</label>
                            
                            <div class="col-sm-8">
                                <select id="school_id" name="school_id" class="form-control" >
                                	<option value="">--选择驾校--</option>
                                	<%for(school in obj.schoolList){%>
                                		 <option value="${school.id}">${school.name}</option>
                                	<%}%>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="school_memo" class="col-sm-2 control-label">驾校备注</label>

                            <div class="col-sm-8">
                                <input type="text" id="school_memo" class="form-control" name="school_memo"  placeholder="驾校备注" >
                            </div>
                        </div>
                    	<div class="form-group">
                        	<label for="headimg" class="col-sm-2 control-label">头像</label>

                            <div class="col-sm-8">
                            	<div id="headimg_queue"></div>
                                <div>
                                	<input id="headimg_file_upload"  type="file" multiple="false">
                                </div>
                                <div id="headimg_img" style="padding: 5px;"></div>
                                <input type="hidden" id="headimg" name="headimg" value="" >
                           	</div>
                       	</div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">名称</label>

                            <div class="col-sm-8">
                                <input type="text" id="name" class="form-control" name="name" data-parsley-required="true" placeholder="名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="mobile" class="col-sm-2 control-label">电话</label>

                            <div class="col-sm-8">
                                <input type="text" id="mobile" class="form-control" name="mobile"  placeholder="电话" data-parsley-required="true" data-parsley-type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="sex" class="col-sm-2 control-label">性别</label>

                            <div class="col-sm-8">
                                 <input type="radio" name="sex" data-parsley-required="true" value="0"  />男
                                 <input type="radio" name="sex" data-parsley-required="true" value="1"  />女
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="id_no" class="col-sm-2 control-label">身份证</label>

                            <div class="col-sm-8">
                                <input type="text" id="id_no" class="form-control" name="id_no"  placeholder="身份证" data-parsley-required="true">
                            </div>
                        </div>
                        <div class="form-group" >
	                 		<label for="birth" class="col-sm-2 control-label">出生日期</label>
	                           	
	                   		<div class="col-sm-3">
	                      		<input type="text" size="16"  class="form-control" value="" data-parsley-required="true" id="birth" name="birth">
	                		</div>
	                    </div>
	                    <div class="form-group">
                            <label for="projects" class="col-sm-2 control-label">选择项目</label>
                            
                            <div class="col-sm-8">
                                <%for(project in obj.projects){%>
                                	<input type="checkbox" name="projects" data-parsley-required="true" value="${project.id}"  />${project.name}
                                <%}%>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="state" class="col-sm-2 control-label">状态</label>

                            <div class="col-sm-8">
                                 <input type="radio" name="state" data-parsley-required="true" value="0"  />启用
                                 <input type="radio" name="state" data-parsley-required="true" value="1"  />禁用
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="grade" class="col-sm-2 control-label">等级</label>

                            <div class="col-sm-8">
                                <input type="text" id="grade" class="form-control" name="grade"  placeholder="等级"  data-parsley-type="number">
                            </div>
                        </div>
                       <!--  <div class="form-group has-feedback">
                            <label for="parentId" class="col-sm-2 control-label">选择场地</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input id="parentId" type="text" class="form-control" placeholder="选择场地" disabled
                                           value="<%if(!isEmpty(obj)){%>${obj.name}<%}%>" data-parsley-required="true"/>

			                             		<span class="input-group-btn">
			                             			<button type="button" class="btn btn-primary" data-toggle="modal"
                                                            data-target="#dialogSelectParentUnit"><i class="ti-plus"></i>选择
                                                    </button>
			                             		</span>
                                </div>
                                <input type="hidden" name="fieldid" value="<%if(!isEmpty(obj)){%>${obj.id}<%}%>">
                            </div>
                        </div> -->
                        <div class="form-group">
                            <label for="memo" class="col-sm-2 control-label">备注</label>

                            <div class="col-sm-8">
                                <textarea rows="5" cols="5" id="memo" class="form-control" name="memo" data-parsley-required="true" data-parsley-maxlength="5000"  placeholder="备注"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
                        </div>
                    </div>
                </div>
            </form>

</div>
</div>
</div>
</div>
</div>
<!-- 选择场地
<div id="dialogSelectParentUnit" class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">选择场地</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div id="jsTreeParentUnit" class="demo"></div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
                <button type="button" class="btn btn-primary" onclick="selectParentMenu()">确认选择</button>
            </div>
        </div>
    </div>
</div>
 -->
<a class="exit-offscreen"></a>
<script language="JavaScript">
	/* function initTreeView() {
	    $("#jsTreeParentUnit").jstree({
	        plugins: ["wholerow","json_data","checkbox","ui",],
	        core: {
	            data: {
	                dataType: "json",
	                url: function (node) {
	                    return node.id === "#" ? "${base}/platform/trainer/tree" : "${base}/platform/trainer/tree?pid=" + node.id
	                }
	            },
	            multiple: true
	        }
	    }).on("dblclick.jstree", function (node) {
	        selectParentMenu();
	    });
	} */
	//选择父菜单
/* 	function selectParentMenu() {
	    var tree = $.jstree.reference("#jsTreeParentUnit");
	    var node = tree.get_selected(true);
	    var namevar= "";
	    var idvar= "";
	    for(var i=0;i<node.length;i++){
	    	namevar+=node[i].text+",";
	    	idvar+=node[i].id+",";
	    }
	    namevar=namevar.substring(0,namevar.length-1);
	    idvar=idvar.substring(0,idvar.length-1);
	    $("#companyAddForm #parentId").val(namevar);
	    $("#companyAddForm input[name='fieldid']").val(idvar);
	    $("#dialogSelectParentUnit").modal("hide");
	} */

	function headimg_clearFile() {
	    $("#headimg_img").html("");
	    $("#headimg_queue").html("");
	    $("#headimg").val("");
	}
    $(document).ready(function () {
    	$.datetimepicker.setLocale('ch');
      	$('#birth').datetimepicker({
     		lang:'ch',
       		timepicker:false,
       		format:'Y-m-d',
       		formatDate:'Y-m-d'
     	});
    	$('#headimg_file_upload').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': '请选择图片',
            'fileType': 'image/*',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'headimg_queue',
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#headimg_img").html("<img src='${AppUploadRoot}" + data.data + "' style='width:150px;height:95px;'>");
                    $("#headimg").val(data.data);
                } else {
                	headimg_clearFile();
                    Toast.error(data.msg);
                }
            },
            'onDrop': function (file, fileDropCount) {
            	headimg_clearFile();
            },
            'onClearQueue': function (queue) {
            	headimg_clearFile();
            },
            'onCancel': function () {
            	headimg_clearFile();
            }
        });
        $('#companyAddForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
            },
            success: function (data, statusText, xhr, form) {
                if (data.code==0) {
                    Toast.success(data.msg);
                    setTimeout(function () {
                        $("#goback").trigger("click");
                    }, 1000);
                } else {
                    Toast.error(data.msg);
                }
            }
        });
    });
</script>
<%}%>